package com.qwiki.text;

import java.util.Collections;
import java.util.List;

/**
 * Corresponds to comment in wikipedia.
 * 
 * @author xgu
 * 
 * @since May 30, 2012
 */
public class CommentNode extends Node
{

  @Override
  public String getText()
  {
    return "";
  }

  @Override
  public List<Node> getChildren()
  {
    return Collections.EMPTY_LIST;
  }

  @Override
  public boolean parse(char[] buffer, int start)
  {
    this.start = start;
    this.buffer = buffer;
    if (match(buffer, start, "<!--"))
    {
      int i = start + 4; // length of begin tag
      while (i < buffer.length)
      {
        if (match(buffer, i, "-->"))
          break;
        i++;
      }
      end = Math.min(i + 3, buffer.length); // length of end tag
      parsed = true;
      return true;
    }
    return false;
  }

}
